package com.bestdreamer.thread_synchronized;

public class Demo1Run {

    public static void main(String[] args) {
        Demo1Task task = new Demo1Task();
        Demo1Thread1 thread1 = new Demo1Thread1(task);
        thread1.start();
        Demo1Thread2 thread2 = new Demo1Thread2(task);
        thread2.start();
        try{
            Thread.sleep(10000);
        }catch (InterruptedException e){
            e.printStackTrace();
        }
        long beginTime = Demo1CommonUtils.beginTime1;
        if(Demo1CommonUtils.beginTime2 < Demo1CommonUtils.beginTime1){
            beginTime = Demo1CommonUtils.beginTime2;
        }
        long endTime = Demo1CommonUtils.endTime1;
        if(Demo1CommonUtils.endTime2 > Demo1CommonUtils.endTime1){
            endTime = Demo1CommonUtils.endTime2;
        }
        System.out.println("耗时：" + ((endTime - beginTime) / 1000));
    }
}
